Replace char occurrences¶
Get a string from a given string where all occurrences of its first char
have been changed to ‘$’, except the first char itself.
Sample String :
‘restart’
Expected Result :
‘resta$t’
def change_char(S):
char = S[0]
S = S.replace(char, '$')
S = char + S[1:]
return S
# test
print(change_char('restart')) # resta$t